package iqq.ui.view.frame;

import iqq.ui.view.ViewManager;
import iqq.ui.view.rootpane.LoginRootPane;
import iqq.ui.view.window.BaseFrame;

import javax.swing.JRootPane;

/**
 * @author ChenZhiHui
 * @create-time 2013-3-6
 */
public class IQQFrame extends BaseFrame {

	private static final long serialVersionUID = 5657068628794542707L;

	private JRootPane windowRoot;
	private JRootPane rootPane;

	public IQQFrame() {
		initRootPane();
	}

	/**
	 * initialization root
	 */
	private void initRootPane() {
		windowRoot = new JRootPane();
		this.add(windowRoot);

		show(LoginRootPane.class);
	}

	public JRootPane show(Class<? extends JRootPane> clazz) {
		rootPane = ViewManager.get(clazz);
		if (rootPane != null) {
			updater();
		}
		return rootPane;
	}

	public void updater() {
		if (rootPane != null) {
			windowRoot.setContentPane(rootPane); // titleComponet依赖默认创建的root

		}
		revalidate();
		repaint();
	}
}
